import { typeEnum } from "@/assets/common/enums";
import type { questionType } from "@/types/index";

//判断是否为基础类型
export const isBasicsOption = (type: typeEnum) => {
  return [typeEnum.RADIO, typeEnum.CHECKBOX, typeEnum.DROP].includes(type);
};

//判断是否为矩阵类型
export const isMatrixOption = (type: typeEnum) => {
  return [typeEnum.MATRIX_RADIO, typeEnum.MATRIX_CHECKBOX, typeEnum.MATRIX_SLIDER].includes(type);
};

//生成列
export const generateColumn = (column: number) => {
  return { gridTemplateColumns: `repeat(${column}, minmax(0, 1fr))` };
};

//选择最大值和最小值
export const chooseMinMax = (question: questionType, isMax = true) => {
  const text = isMax ? "多" : "少";
  let options = [{ value: 0, label: `最${text}选几项`, disabled: false }];
  for (let i = 0; i <= question.option.length; i++) {
    let index = i + 1;
    options.push({
      value: index,
      label: `最${text}选${index}项`,
      disabled: isMax ? question.chooseMin !== 0 && question.chooseMin > index : question.chooseMax !== 0 && question.chooseMax <= index
    });
  }
  return options;
};
